package com.kotlin.lib.clazz

private open class Base(name: String) {
    init {
        println("base init method.")
    }

    open var size = name.length.also { println("base:size=${it}") }
}

private class Derived(firstName: String, secondName: String) : Base(firstName.capitalize().also {
    println("argument for base:$it")
}) {

    init {
        println("Derived init method")
    }

    override var size: Int = (firstName + secondName).length.also {
        println("Derived:size =$it")
    }
}

/**
 * 在构造派生类的新实例的过程中，第一步完成其基类的初始化（在之前只有对基类构造函数参数的求值），因此发生在派生类的初始化逻辑运行之前
 */
fun main() {
    Derived("it", "are")
    getInt(value = 2,default = 0)

    println( "s".equals("s"))
}


private fun getDefaultValue(): String {
    return "s"
}

private fun getInt(
    key: String = getDefaultValue(),
    value: Int,
    default: Int = -1,
    fileName: String = "abc.txt"
) {
    println("key:$key")
}